//
//  StockUnitDivitionJa.m
//  MarketDataAnalyzer
//
//  Created by jiro on 10/01/26.
//  Copyright 2010 jiro music. All rights reserved.
//

#import "StockUnitDivitionJa.h"
#import "../DbConstants.h"

@implementation StockUnitDivitionJa

@synthesize code;

@synthesize divisionDate;

@synthesize unitDivided;

+ (NSString*) tableName
{
	return kText_StockUnitDivisionJaTable;
}

+ (NSString*) queryCreateTable
{
	NSString* s = [ NSString stringWithFormat: 
		@"create table %@( %@ %@, %@ %@, %@ %@, %@( %@, %@ ) );",
		kText_StockUnitDivisionJaTable, 
		kText_Code, kText_Text,
		kText_DivisionDate, kText_TimestampWithTimeZone,
		kText_UnitDivided, kText_Real,
		kText_PrimaryKey, kText_Code, kText_DivisionDate
	];
	return s;
}

- (NSString*) sqlInsertStatement
{
	return [ NSString stringWithFormat: @"insert into %@ values %@",
		kText_StockUnitDivisionJaTable, [ self queryInsertValue ] ];
}

+ (NSString*) querySelectAll
{
	NSString* s = [ NSString stringWithFormat: @"select * from %@;", [ StockUnitDivitionJa tableName ] ];
	return s;
}

- (NSString*) queryInsert
{
	NSString* s = [ NSString stringWithFormat: @"insert into * values %@;", 
		[ StockUnitDivitionJa tableName ], [ self queryInsertValue ] ];
	return s;
}

- (NSString*) queryInsertValue
{
	return [ NSString stringWithFormat: @"( '%@', '%@', %f )",
		code, [ divisionDate description ], unitDivided ];
}

@end
